<template>
  <div ref="myChart" id="myChart"></div>
</template>

<script>
import * as echarts from "echarts";
export default {
  mounted() {
    let myChart = echarts.init(this.$refs.myChart);
    let dataD = [150, 230, 224, 218, 135, 147, 260];
    let dataA = [60, 90, 100, 300, 40, 20, 10];
    let dataB = [30, 90, 10, 218, 267, 346, 260];
    let dataC = [10, 100, 150, 123, 312, 345, 222];
    let xData = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
    let option = {
      title: {
        text: "饼状图",
        left: "center",
      },
      xAxis: {
        type: "category",
        data: xData,
      },
      yAxis: {
        type: "value",
      },
      series: [
        {
          name: "美食A",
          type: "line",
          // 数据堆叠
          stack: "num", // 同类型的数据需要匹配相同的stack值
          data: dataA,
          smooth: true,
          // 样式填充
          areaStyle: {},
          // 选中高亮状态
          emphasis: {
            focus: "series", // 聚焦当前的高亮区域
          },
        },
        {
          name: "美食B",
          type: "line",
          // 数据堆叠
          stack: "num", // 同类型的数据需要匹配相同的stack值
          smooth: true,
          areaStyle: {},
          data: dataB,
          emphasis: {
            focus: "series", // 聚焦当前的高亮区域
          },
        },
        {
          name: "美食C",
          type: "line",
          // 数据堆叠
          stack: "num", // 同类型的数据需要匹配相同的stack值
          smooth: true,
          areaStyle: {},
          data: dataC,
          emphasis: {
            focus: "series", // 聚焦当前的高亮区域
          },
        },
        {
          name: "美食D",
          type: "line",
          // 数据堆叠
          stack: "num", // 同类型的数据需要匹配相同的stack值
          smooth: true,
          areaStyle: {},
          data: dataD,
          emphasis: {
            focus: "series", // 聚焦当前的高亮区域
          },
        },
      ],
    };
    myChart.setOption(option);
  },
};
</script>

<style>
#myChart {
  width: 500px;
  height: 500px;
  border: 1px solid #333;
}
</style>